$('#login-button').click(function () {
    //  console.log("ss")
    let username = $('#username').val()
    let pwd = $('#pwd').val()
   
   ajax({
       url:"dl/dist/denglu.php",
       data:{
           username:username,
           pwd:pwd,
       },
       type:"GET",
       callback:function(res){
        //    console.log(res)
           var res=JSON.parse(res)
           
           if(res.code===0){
               alert(res.msg)
                var d = new Date();
                d.setDate( d.getDate() + 1 );
                cookie("username",username,{expires:1})
                cookie("pwd",pwd,{expires:1})
                var userName = document.cookie.split("; ")[0].split("=")[1]
                window.location.href="index.html?username="+userName
               
           }
           else if(res.code===1){
               console.log(res)
               alert(res.msg)   
           }   
           else if(res.code===2){
            alert(res.msg)   
            // var d = new Date();
            // d.setDate( d.getDate() + 1 );
            // document.cookie= `name=${username};expires=${d}`
           }
       }
   })
  
})
if(document.cookie){
    $('#username').val(cookie('username'))
    $('#pwd').val(cookie('pwd'))
    $('#rember_login').prop('checked',true)
 }
 let a= $('#rember_login').prop('checked')
 if(a==true){
    cookie('username',username,{expires:1})
    cookie('pwd',pwd,{expires:1})
     // username=cookie()
  console.log("Aaa")
 }

var user = document.cookie.split("; ")[0].split("=")[1]
var url = window.location.href
if(document.cookie && url.includes("username=")==false){
    $('#username').val("")
    $('#pwd').val("")
    $('#rember_login').prop('checked',false)
}

